package org.aurora.framework.boot.data.mybatis.audit;

import com.mybatisflex.annotation.UpdateListener;
import org.aurora.framework.boot.data.common.dataobject.AuditDO;

import java.time.LocalDateTime;
import java.util.Objects;

/**
 * name: AuditUpdateListener
 * <p>
 * desc: Audit information update listener
 * <p>
 * create date: 2024-09-25 17:25:18
 *
 * @author cao.yong
 */
public class AuditUpdateListener implements UpdateListener {
    @Override
    public void onUpdate(Object o) {
        if (Objects.nonNull(o) && o instanceof AuditDO<?> auditDO) {
            auditDO.setLastModifiedDate(LocalDateTime.now());
        }
    }
}
